import request from '@/utils/request'

//保存接口
export const saveCustomerApi = (data) => request.post('customer/save', data)

//分页查询
export const pageCustomerApi = (params) => {
  const { page, size, ...rest } = params

  // 手动拼接成 query string 参数
  const query = new URLSearchParams({
    page: page.toString(),
    size: size.toString(),
    ...Object.fromEntries(
      Object.entries(rest).filter(([_, v]) => v !== '' && v !== null && v !== undefined)
    )
  })

  return request.get(`customer/page?${query.toString()}`)
}